using RndMaterialDisposalService.Models.Entitys;
using RndMaterialDisposalService.Models.RequestModel;
using RndMaterialDisposalService.Services.Interface;
using RndMaterialDisposalService.Services.VehicleDispatchService;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Text.Json;

namespace RndMaterialDisposalService.Pages.EmailTemplates.WorkshopProcessing
{
    /// <summary>
    /// 
    /// </summary>
    [IgnoreAntiforgeryToken]
    public class NotifyProviderEmailModel : PageModel
    {
        private readonly IInternalVehicleService internalVehicleService;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="_vehicleMaintenanceService"></param>
        public NotifyProviderEmailModel(IInternalVehicleService _vehicleMaintenanceService)
        {
            internalVehicleService = _vehicleMaintenanceService;
        }

        /// <summary>
        /// 
        /// </summary>
        [BindProperty]
        public ConfirmationExpenseDto FormData { get; set; } = default!;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="formdata"></param>
        /// <returns></returns>
        public void OnPost([FromBody] ConfirmationExpenseDto formdata)
        {
            FormData = formdata;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="formid"></param>
        /// <returns></returns>
        public async Task<IActionResult> OnGetAsync(int? formid)
        {
            if (formid == null)
            {
                return NotFound();
            }
            FormData = await internalVehicleService.GetConfirmationExpenseFormData($"{formid}");
            return Page();
        }
    }
}
